<?php
	require_once("../conexion/conexion.php");
	require_once("../Mantenedores/cliente.php");
	$cli = new Cliente();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin t&iacute;tulo</title>
<link href="../Estilos/global.css" rel="stylesheet" type="text/css" />
<link href="../Estilos/local.css" rel="stylesheet" type="text/css" />
<link href="../Estilos/CssTabla3.css" rel="stylesheet" type="text/css" />
<script src="../include_js/jquery.js" type="text/javascript"></script>
<style>
.filaPar
{
	background:#81D371; 
	font-family:Verdana, Arial, Helvetica, sans-serif; 
    font-size:11px;
	text-align:center;
	vertical-align:middle;
}
.filaImpar
{
	background:#AEF1A1;
	font-family:Verdana, Arial, Helvetica, sans-serif; 
    font-size:11px;
	text-align:center;
	vertical-align:middle;
}
.radioPar
{
	background:#81D371;
	border-color:#81D371;
}
.radioImpar
{
	background:#AEF1A1;
	border-color:#AEF1A1;
}

</style>
<script>
function CargaFacturaOtros(num,listaOtros)
{
	listaOtros = document.getElementById(listaOtros);
	orden = document.getElementById("tablaOtros").rows[num].cells[0].innerText;
	cliente = document.getElementById("tablaOtros").rows[num].cells[1].innerText;
	precio = document.getElementById("tablaOtros").rows[num].cells[4].innerText;
	//alert(cliente);
	$.ajax({
            type: 'POST',
            url: 'Contabilidad/carga_factura_otros.php',
            data: {orden:orden,precio:precio,cliente:cliente},
            success: function(data) {
                $(listaOtros).html(data);
            }
        })
}
</script>
</head>

<body>
<form name="form_fac_ambiental" id="form_fac_ambiental" method="post">
<?php
	extract($_POST);

	if(($cmb_tipo!='0')and($cmb_Mes!='0'))
	{
		$con = new Conexion();
		$con2 = $con->conexionBD("fpproduccion");
		$sql = "select 
					OtrosNumOrden,
					OCliRSocial,
					OtrosResponsable,
					date_format(OtrosFecha,'%d/%m/%Y') as fecha,
					OtrosValor
					
					from otros
					inner join otrosclientes on
					otrosclientes.OCliRut=otros.OCliRut
				
			where otros.OCliRut='".$cmb_cliente."' and OtrosEstado='PENDIENTE' and TOtrosCod='".$cmb_tipo."'";
		$res= mysql_query($sql) or die ($con->error_mysql("Error en la consulta".mysql_error()));
		$fila = mysql_num_rows($res);

		if($fila >0)
		{
		?>
  			<div class='option2'><label style="font:Verdana, Arial, Helvetica, sans-serif; color:#0066CC; font-weight:bold;">Seleccione, para facturar.</label></div>
			<table width="100%" border="0" class="uno" cellpadding="0" cellspacing="0" id="tablaOtros">
			<thead>
  			<tr>
    			<th width="13%">N&deg; factura</th>
    			<th width="35%">cliente</th>
    			<th width="23%">responsable</th>
    			<th width="13%">fecha</th>
				<th width="14%">Valor ($)</th>
				<th width="2%">&nbsp;</th>
  			</tr>
 			</thead>
			<?php
			$cont=1;
			while($row = mysql_fetch_array($res))
			{
				if(($cont % 2)==0)
				{
					/*echo "<tbody class=\"filaPar\">";*/
					echo "<tr class=\"filaPar\">";
					echo "<td width=\"13%\" style='text-align:center;vertical-align:middle;'>".$row['OtrosNumOrden']."</td>";
					echo "<td width=\"35%\" style=\"vertical-align:middle;\">".$row['OCliRSocial']."</td>";
					echo "<td width=\"23%\" style=\"vertical-align:middle;\">".$row['OtrosResponsable']."</td>";
					echo "<td width=\"13%\" style='text-align:center;vertical-align:middle;'>".$row['fecha']."</td>";
					echo "<td width=\"14%\" style='text-align:center;vertical-align:middle;'>".number_format ($row['OtrosValor'],0,',','.')."</td>";
					echo "<td width=\"2%\" class=\"filaPar\"><input name=\"opcion\" class=\"radioPar\" type=\"radio\" value=\"$cont\" onclick=\"CargaFacturaOtros(this.value,'capa');\" /></td>";
					echo "</tr>";
					/*echo "</tbody>";*/
				}
				else
				{
					/*echo "<tbody class=\"filaImpar\">";*/
					echo "<tr class=\"filaImpar\">";
					echo "<td width=\"13%\" style='text-align:center;vertical-align:middle;'>".$row['OtrosNumOrden']."</td>";
					echo "<td width=\"35%\" style=\"vertical-align:middle;\">".$row['OCliRSocial']."</td>";
					echo "<td width=\"23%\" style=\"vertical-align:middle;\">".$row['OtrosResponsable']."</td>";
					echo "<td width=\"13%\" style='text-align:center;vertical-align:middle;'>".$row['fecha']."</td>";
					echo "<td width=\"14%\" style='text-align:center;vertical-align:middle;'>".number_format ($row['OtrosValor'],0,',','.')."</td>";
					echo "<td width=\"2%\"class=\"filaImpar\"><input name=\"opcion\" class=\"radioImpar\" type=\"radio\" value=\"$cont\" onclick=\"CargaFacturaOtros(this.value,'capa');\" /></td>";
					echo "</tr>";
					/*echo "</tbody>";*/
				}
					$cont++;
			}
			$con->cerrarBD();
			?>
			</table>
			<table width="100%" cellpadding="0" cellspacing="0" border="0">
			<tr><td><div id="capa"></div></td></tr>
			</table>
		<?php
		}
		else
		{
            echo "<label style=\"font:Verdana, Arial, Helvetica, sans-serif; color:#0066CC; font-weight:bold;\">No Existen Resultados</label>";
        }
	}
    else
    {
        echo "<label style=\"font:Verdana, Arial, Helvetica, sans-serif; color:#0066CC; font-weight:bold;\">SELECCIONE SERVICIO Y MES</label>";
    }

?>
</form>
</body>
</html>